﻿<%@ Page Language="C#" AutoEventWireup="true" MasterPageFile="~/WebSite.Master" CodeBehind="EnterpriseSelect.aspx.cs" Inherits="RN.ERP.Web.Enterprise.EnterpriseSelect" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <link rel="Stylesheet" type="text/css" href="../Scripts/ligerUI/skins/Aqua/css/ligerui-all.css" />
    <link href="../Styles/skins/blue/css/style_msg.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="../Scripts/ligerUI/js/ligerui.min.js"></script>
    <script type="text/javascript" src="../Scripts/EnterpriseCorpList.js"></script>
    <script type="text/javascript">
        var empGuid;
        var flag;
        var gid;
        var entityid;
        $(function () {
            empGuid = $("#<%= hdEmpGuid.ClientID%>").val();
            flag = $("#<%= hdFlag.ClientID%>").val();
            gid = $("#<%= hdGid.ClientID%>").val();
            entityid = $("#<%= hdEntityGuid.ClientID%>").val();

            if ($("#<%= hdStatus.ClientID%>").val() == "1") {
                $("input[type=checkbox][value*=" + entityid + "]").each(function () {
                    $(this).attr("checked", true);
                });
            }

            $("#btnSearch").click(function () {
                $("#<%= hdnCondition.ClientID %>").val("");
                $find("<%= RadAjaxManager1.ClientID %>").ajaxRequest("Rebind");
            });

            $("#btnSave").click(function () {
                var corpname = $("#<%= txtCorp.ClientID%>").val();
                if (!corpname) {
                    OpenAlert("请输入单位名称");
                }
                else {
                    $.getJSON("../handlers/PsnEmpInfoHandler.ashx", { "action": "RelationSave", "empGuid": empGuid, "gid": gid, "Flag": flag, "EntityName": corpname, "ClassId": 1001, "rand": Math.random() }, function (data) {
                        if (data.length == 0 || data == null) {
                            OpenAlert("未查询到有效数据！");
                            return false;
                        }
                        if (!data.Result) {
                            OpenAlert(data.Message);
                            return false;
                        }
                        else {
                            OpenAlert(data.Message);
                            returnToParent(0);
                        }
                    });
                }
            });

        }
);

        function CheckSel() {
            var chk = $("input:checked");
            if (chk.length == 0) {
                $.ligerDialog.warn("请选择企业！");
                return false;
            }
            if (chk.length > 1) {
                $.ligerDialog.warn("请选择一家企业进行操作！");
                return false;
            }
            var guid = chk.attr("value").split(';')[0];
            var name = chk.attr("value").split(';')[1];
            $.getJSON("../handlers/PsnEmpInfoHandler.ashx", { "action": "RelationSave", "empGuid": empGuid, "gid": gid, "Flag": flag, "EntityGuid": guid, "EntityName": name, "rand": Math.random() }, function (data) {
                if (data.length == 0 || data == null) {
                    OpenAlert("未查询到有效数据！");
                    return false;
                }
                if (!data.Result) {
                    OpenAlert(data.Message);
                    return false;
                }
                else {
                    OpenAlert(data.Message);
                    returnToParent(0);
                }
            });
        }
        function ShowCorpView(corpGuid) {
            top.ChildDialogWin = window;
            top.ChildDialog = top.$.ligerDialog.open({ url: "../Enterprise/EnterpriseCorpInfo.aspx?corpUserGuid=" + corpGuid, width: 1180, height: 800, title: '', buttons: [{ text: '关闭', onclick: function (item, dialog) { dialog.close(); } }] });
            top.setChildDialogClose(this, "RefreshGrid");
            //  window.location.href = '../Enterprise/EnterpriseCorpInfo.aspx?corpUserGuid=' + guid;
        }
        function RefreshGrid(condition) {
            $("#<%= hdnCondition.ClientID %>").val(condition);
            $find("<%= RadAjaxManager1.ClientID %>").ajaxRequest("Rebind");
        }

        /*关闭窗口*/

        function returnToParent(result) {
            var oArg = new Object();
            oArg.childWinName = "Relation";
            oArg.Result = result;
            //        top.ChildDialogCallBack = "OnClientClose";
            //        top.ChildDialogClose(oArg);
            parent.window.OnClientClose(oArg);
            window.parent.$.ligerDialog.close(); ////关闭dialog
            parent.$(".l-dialog,.l-window-mask").hide(); ////去除父窗体遮罩层
            parent.window.focus();
        }
        function OpenAlert(text) {
            $.ligerDialog.warn(text);
            return false;
        }

        function selectTag(showContent, selfObj) {
            // 操作标签
            var tag = document.getElementById("tags").getElementsByTagName("li");
            var taglength = tag.length;
            for (i = 0; i < taglength; i++) {
                tag[i].className = "";
            }
            selfObj.parentNode.className = "selectTag";
            // 操作内容
            for (i = 0; j = document.getElementById("tagContent" + i); i++) {
                j.style.display = "none";
            }
            document.getElementById(showContent).style.display = "block";
        }

    </script>
    <style type="text/css">
        .text_css
        {
            border: 2px;
            height: 24px;
            line-height: 24px;
            margin-top: 8px;
        }
    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" OnAjaxRequest="RadAjaxManager1_AjaxRequest">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="RadAjaxManager1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="ListCorps" LoadingPanelID="RadAjaxLoadingPanel1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
    <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" />
    <table width="100%" border="0" cellspacing="0" cellpadding="0" align="center" style="table-layout:fixed;">
        <tr>
            <td class="xx_m  tt_xx_l"></td>
            <td class="xx_m  tt_xx_icon"></td>
            <td style="width:auto;" class="xx_m">企业列表</td>
            <td style="width:14px;"><img src="../images/xx_r.jpg" width="14" height="33" /></td>
        </tr>
        <tr>
            <td class="left_con">
                &nbsp;
            </td>
            <td colspan="2" style="padding-left: 6px; padding-right: 6px;" valign="top">
            <div id="con">
            <ul id="tags">
                <li class="selectTag"><a onclick="selectTag('tagContent0',this)" href="javascript:void(0)">
                    单位列表</a> </li>
                <li><a onclick="selectTag('tagContent1',this)" href="javascript:void(0)">手动添加</a></li>
            </ul>
            <div id="tagContent">
                <!--#企业列表-->
                <div class="tagContent selectTag" id="tagContent0">
                    <div class="xian">
                        <div class="about_title">
                            请选择利害关系单位</div>
                        <div class="i-con-cn">
                            <input type="button" class="xtbiao" id="btnSearch" value="查询" />
                            <input type="button" class="xtbiao" onclick="CheckSel()" value="选择企业" />
                        </div>
                    </div>
                    <asp:Panel ID="Panel1" runat="server" Style="margin-bottom: 5px;">
                        <table style="width: 100%; height: 40px; padding-bottom: 10px; padding-top: 10px;
                            background-color: #eaeaea; text-align: center;">
                            <tr>
                                <td width="50">
                                    单位名称
                                </td>
                                <td width="110">
                                    <div class="s_input">
                                        <span class="input_l">
                                            <img src="../images/input_l.jpg" width="10" height="31" alt="" /></span> <span class="input_mm">
                                                <asp:TextBox ID="txtCorpName" runat="server" Style="width: 200px; height: 31px; line-height: 31px;
                                                    border: 0; background: transparent"></asp:TextBox>
                                            </span><span class="input_r">
                                                <img src="../images/input_r.jpg" width="10" height="31" alt="" /></span>
                                    </div>
                                </td>
                            </tr>
                        </table>
                    </asp:Panel>
                    <telerik:RadGrid ID="ListCorps" runat="server" AutoGenerateColumns="False" CellSpacing="0"
                        Width="100%" Culture="zh-CN" GridLines="None" AllowFilteringByColumn="false"
                        AllowPaging="true" AllowCustomPaging="true" AllowMultiRowSelection="true" OnNeedDataSource="ListCorps_NeedDataSource"
                        AllowSorting="false" ShowStatusBar="true">
                        <ClientSettings ReorderColumnsOnClient="True" AllowColumnsReorder="True" EnableRowHoverStyle="true">
                            <Resizing AllowRowResize="True" EnableRealTimeResize="True" ResizeGridOnColumnResize="True"
                                AllowColumnResize="True"></Resizing>
                        </ClientSettings>
                        <MasterTableView AutoGenerateColumns="false" DataKeyNames="ID">
                            <CommandItemSettings ExportToPdfText="导出PDF" />
                            <RowIndicatorColumn FilterControlAltText="Filter RowIndicator column" Visible="True">
                            </RowIndicatorColumn>
                            <Columns>
                                <telerik:GridTemplateColumn HeaderText="选择" HeaderStyle-Width="50px">
                                    <ItemTemplate>
                                        <input id="ckb" type="checkbox" value='<%#Eval("CorpUserGuid")+";"+Eval("CorpName")%>'
                                            runat="server" />
                                    </ItemTemplate>
                                    <ItemStyle Width="50px"></ItemStyle>
                                </telerik:GridTemplateColumn>
                                <telerik:GridTemplateColumn DataField="ID" HeaderText="ID" UniqueName="ID" ReadOnly="true"
                                    Visible="false">
                                </telerik:GridTemplateColumn>
                                <telerik:GridTemplateColumn DataField="CorpName" HeaderText="企业名称">
                                    <ItemTemplate>
                                        <a href="javascript:void(0);"
                                            title="点击查看企业信息"><span style="color: #43a9f5">
                                                <%#Eval("CorpName")%></span></a>
                                    </ItemTemplate>
                                </telerik:GridTemplateColumn>
                                <telerik:GridTemplateColumn DataField="Address" HeaderText="企业地址" ItemStyle-Width="100px">
                                    <ItemTemplate>
                                        <%#Eval("Address") == null ? "" : (Eval("Address").ToString().Length<15?Eval("Address").ToString():Eval("Address").ToString().Substring(0, 15))%>
                                    </ItemTemplate>
                                </telerik:GridTemplateColumn>
                                <telerik:GridTemplateColumn  HeaderText="企业类型" HeaderStyle-Width="100px">
                                    <ItemTemplate>
                                        <%#Eval("RoleId") == null ? "" : GetCorpClassKind(Eval("RoleId").ToString())%>
                                    </ItemTemplate>
                                </telerik:GridTemplateColumn>
                                <telerik:GridTemplateColumn DataField="DetailName" HeaderText="主项资质" HeaderStyle-Width="200px">
                                    <ItemTemplate>
                                        <%#Eval("DetailName") == null ? "" : (Eval("GradeName") == null ? Eval("DetailName").ToString() : Eval("DetailName").ToString() + "-" + Eval("GradeName").ToString())%>
                                    </ItemTemplate>
                                </telerik:GridTemplateColumn>
                                <telerik:GridBoundColumn DataField="LinkMan1" HeaderText="联系人" HeaderStyle-Width="60px">
                                </telerik:GridBoundColumn>
                                <telerik:GridBoundColumn DataField="Tel" HeaderText="联系方式" HeaderStyle-Width="150px">
                                </telerik:GridBoundColumn>
                                <telerik:GridBoundColumn DataField="StrFlowCode" HeaderText="审核状态" HeaderStyle-Width="100px">
                                </telerik:GridBoundColumn>
                            </Columns>
                        </MasterTableView>
                        <ClientSettings EnableRowHoverStyle="true">
                        </ClientSettings>
                        <PagerStyle AlwaysVisible="True" />
                        <FilterMenu EnableImageSprites="False">
                        </FilterMenu>
                    </telerik:RadGrid>
                </div>
                <!--#企业列表结束-->
                <!--#手动添加-->
                <div class="tagContent" id="tagContent1">
                      <table style="width: 100%; height: 100px; padding-bottom: 10px; padding-top: 10px;
                            background-color: #eaeaea; text-align: center;">
                            <tr>
                                <td width="50">
                                    单位名称
                                </td>
                                <td width="110">
                                    <div class="s_input">
                                        <span class="input_l">
                                            <img src="../images/input_l.jpg" width="10" height="31" alt="" /></span> <span class="input_mm">
                                                <asp:TextBox ID="txtCorp" runat="server" Style="width: 200px; height: 31px; line-height: 31px;
                                                    border: 0; background: transparent"></asp:TextBox>
                                            </span><span class="input_r">
                                                <img src="../images/input_r.jpg" width="10" height="31" alt="" /></span>
                                    </div>
                                </td>
                            </tr>
                            <tr>
                            <td colspan="2" align="center">
                                        <div class="icon01 IE6png" style="float:left;margin-left:300px" >
                                            <a style="clear:both;" id="btnSave" href="javascript:void(0);">保存</a>
                                        </div>
                            </td>
                            </tr>
                        </table>
                </div>
                <!--#手动添加-->
                </div>
                </div>
            </td>
            <td class="right_con">
                &nbsp;
            </td>
        </tr>
        <tr>
            <td class="con_m tt_left_bottom">&nbsp;</td>
            <td colspan="2" class="con_m">&nbsp;</td>
            <td class="tt_right_bottom">&nbsp;</td>
        </tr>
    </table>
    <telerik:RadWindowManager ID="RadWindowManager1" runat="server" Skin="WebBlue" EnableShadow="true">
    </telerik:RadWindowManager>
    <asp:HiddenField ID="hdnClassID" runat="server" />
    <asp:HiddenField ID="hdnCondition" runat="server" />
    <input id="hdEmpGuid" type="hidden" runat="server" value="" /> 
    <input id="hdFlag" type="hidden" runat="server" value="" />
    <input id="hdGid" type="hidden" runat="server" value="" />
    <input id="hdEntityGuid" type="hidden" runat="server" value="" />
    <input id="hdStatus" type="hidden" runat="server" value="0" />
</asp:Content>
